/**
  ******************************************************************************
  * @file    Project/main.c 
  * @author  MCD Application Team
  * @version V2.3.0
  * @date    16-June-2017
  * @brief   Main program body
   ******************************************************************************
  * @attention
  *
  * <h2><center>&copy; COPYRIGHT 2014 STMicroelectronics</center></h2>
  *
  * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
  * You may not use this file except in compliance with the License.
  * You may obtain a copy of the License at:
  *
  *        http://www.st.com/software_license_agreement_liberty_v2
  *
  * Unless required by applicable law or agreed to in writing, software 
  * distributed under the License is distributed on an "AS IS" BASIS, 
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  *
  ******************************************************************************
  */ 


/* Includes ------------------------------------------------------------------*/
#include "stm8s.h"

/* Private defines -----------------------------------------------------------*/
#include "GPIO.h"
#include "RS485.h"
#include "TIM1_PWM.h"

#include "osal.h"
#include "osal_event.h"
#include "osal_memory.h"
/* Private function prototypes -----------------------------------------------*/
/* Private functions ---------------------------------------------------------*/
/* 
USE_STM8_128_EVAL
USE_STDPERIPH_DRIVER
*/
void OSstart(void);


static void CLK_Config(void)
{
    /* Initialization of the clock */
    /* Clock divider to HSI/1 */
	/*!< High speed internal clock prescaler: 1 */
/* 	Configure system clock to run at 16Mhz*/ 
	CLK_HSIPrescalerConfig(CLK_PRESCALER_HSIDIV1);
	CLK_HSICmd(ENABLE);
}
static void HardwareInit()
{
 	CLK_Config();
	GPIO_Config();
	UART_Config();
	TIM1_Config();
	Check_TIM1_CH1CH2_OptionByte();


}
void main(void)
{
/* 	CLK_Config();
	GPIO_Config();
	UART_Config();
	TIM1_Config();
	Check_TIM1_CH1CH2_OptionByte();


  while (1)
  {
		RS485_lamp();
  }
   */



}
//--------------------------------------------------

void OSstart()
{

	//系统硬件、外设等初始化
	HardwareInit();

	//禁止中断
    HAL_DISABLE_INTERRUPTS();

// 	/* Initialize NV system */
//   osal_snv_init();

	//osal操作系统初始化
    osal_init_system();

	//添加任务
	// osal_add_Task(Serial_Task_Init,Serial_Task_EventProcess,1);	
	//添加的任务统一进行初始化
	osal_Task_init();

	osal_mem_kick();

	//允许中断
	HAL_ENABLE_INTERRUPTS();	

	//设置初始任务事件，上电就需要自动轮询的任务事件可在此添加
	// osal_start_reload_timer( Serial_TaskID, PRINTF_STR, 1000);

	//启动osal系统，不会再返回
	osal_start_system();

}

#ifdef USE_FULL_ASSERT

/**
  * @brief  Reports the name of the source file and the source line number
  *   where the assert_param error has occurred.
  * @param file: pointer to the source file name
  * @param line: assert_param error line source number
  * @retval : None
  */
void assert_failed(u8* file, u32 line)
{ 
  /* User can add his own implementation to report the file name and line number,
     ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */

  /* Infinite loop */
  while (1)
  {
  }
}
#endif


/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
